package com.iob.coin.DAO;

import com.iob.coin.po.Type;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @Author: MengYuxin
 * @Date: 2021/4/13 22:04
 */public interface TypeDAO extends JpaRepository<Type,Integer> {

     @Query(nativeQuery = true,value = "select id from se3.type where node_type=?1 and kgID=?2")
     int findID(String node_type,int kgID);

     @Query(nativeQuery = true,value = "select node_type from se3.type where id=?1 and kgID=?2")
     String getNodeType(int id,int kdID);

     List<Type>findByKgID(int kgID);

     @Query(nativeQuery = true,value = "select count(*) from se3.type where kgID=?1 and node_type=?2")
     int countType(int kgID,String node_type);

     void deleteByIdAndKgID(int id,int kgID);

     List<Type>findById(int id);

     void deleteByKgID(int kgID);

     @Modifying
     @Query(nativeQuery = true,value = "insert into se3.type " +
             "(id, kgID, node_type, color, radius) " +
             "values (?1,?2,?3,?4,?5)")
     void insert_when_cancel(int id,int kgID,String node_type,String color,double radius);




}
